package com.microservice.schedule;

import com.microservice.utils.Commons;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import com.microservice.utils.MyDateTimeUtils;

import java.util.Date;

@Component
public class ScheduleMissYou {

    @Scheduled(cron="0/30 * * * * ?")//每10S执行一次
    public void scheduleMissYou() throws Exception {
        Commons.missYouNum ++ ;
        MyDateTimeUtils myDateTimeUtils = new MyDateTimeUtils();
        String time = MyDateTimeUtils.DateTimeToStr(new Date(),"yyyy-MM-dd HH:mm:ss");
        StringBuffer printlnStr = new StringBuffer();
        printlnStr.append(time);
        printlnStr.append(":每30秒我就想你一次,从我启动起来开始我已经想了你一共");
        printlnStr.append(Commons.missYouNum);
        printlnStr.append("次!");
        System.out.println(printlnStr.toString());
    }
}
